package com.freedom.ums.member.infrastructure.enums;

import com.freedom.common.core.result.BaseResultCode;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@AllArgsConstructor
@NoArgsConstructor
public enum UMSResultCodeEnum implements BaseResultCode, Serializable {

    U_MEMBER_NOT_EXIST("U0201", "用户不存在"),
    U_MEMBER_ACCOUNT_LOCKED("U0202", "用户账户被冻结"),
    U_MEMBER_ACCOUNT_LOG_OUT("U0203", "用户账户已注销"),
    U_ACCOUNT_EXIST("U0204", "用户账号已存在"),
    U_INVITE_MEMBER_NOT_EXIST("U0205", "邀请人用户不存在"),


    USER_NOT_EXIST("A0201", "用户不存在"),
    USER_ACCOUNT_UNAVAILABLE("A0202", "用户账号不可用"),
    USER_ACCOUNT_LOCKED("A0203", "用户账户被冻结"),
    USER_ACCOUNT_INVALID("A0204", "用户账户已作废"),
    USER_ACCOUNT_TIME_OUT("A0204", "用户账户已过期"),

    USERNAME_OR_PASSWORD_ERROR("A0210", "用户名或密码错误"),
    PASSWORD_ENTER_EXCEED_LIMIT("A0211", "用户输入密码次数超限"),
    CLIENT_AUTHENTICATION_FAILED("A0212", "客户端认证失败"),
    TOKEN_INVALID_OR_EXPIRED("A0230", "token无效或已过期"),
    TOKEN_ACCESS_FORBIDDEN("A0231", "token已被禁止访问"),

    AUTHORIZED_ERROR("A0300", "访问权限异常"),
    ACCESS_UNAUTHORIZED("A0301", "访问未授权"),
    FORBIDDEN_OPERATION("A0302", "演示环境禁止修改、删除重要数据，请本地部署后测试"),


    PARAM_ERROR("A0400", "请求参数错误"),
    RESOURCE_NOT_FOUND("A0401", "请求资源不存在"),
    PARAM_IS_NULL("A0410", "请求必填参数为空"),

    USER_UPLOAD_FILE_ERROR("A0700", "用户上传文件异常"),
    USER_UPLOAD_FILE_TYPE_NOT_MATCH("A0701", "用户上传文件类型不匹配"),
    USER_UPLOAD_FILE_SIZE_EXCEEDS("A0702", "用户上传文件太大"),
    USER_UPLOAD_IMAGE_SIZE_EXCEEDS("A0703", "用户上传图片太大"),


    STORE_NOT_EXIST("50001", "此店铺不存在"),
    STORE_NAME_EXIST_ERROR("50002", "店铺名称已存在!"),
    STORE_APPLY_DOUBLE_ERROR("50003", "已有店铺，无需重复申请!"),
    STORE_NOT_OPEN("50004", "该会员未开通店铺"),
    STORE_NOT_LOGIN_ERROR("50005", "未登录店铺"),
    STORE_CLOSE_ERROR("50006", "店铺关闭，请联系管理员"),



    ;

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    private String code;

    private String msg;

    @Override
    public String toString() {
        return "{" +
                "\"code\":\"" + code + '\"' +
                ", \"msg\":\"" + msg + '\"' +
                '}';
    }


    public static UMSResultCodeEnum getValue(String code){
        for (UMSResultCodeEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
